<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改排班计划')" />
</head>
<body class="white-bg">
<!--    <div class="wrapper wrapper-content animated fadeInRight ibox-content">-->
<!--        <form class="form-horizontal m" id="form-plan-edit" th:object="${hisSchedulePlan}">-->
<!--            <input name="id" th:field="*{id}" type="hidden">-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label is-required">班次ID：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="sid" th:field="*{sid}" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label is-required">员工ID：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="uid" th:field="*{uid}" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label is-required">星期：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="weekDay" th:field="*{weekDay}" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label is-required">值班：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="duty" th:field="*{duty}" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
<!--        </form>-->
<!--    </div>-->
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>班组：</label>
                                <input type="text" th:value="${teamGroup.teamName}" disabled/>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-height">
                <div class="bootstrap-table bootstrap3">
                    <div class="fixed-table-container" style="padding-bottom: 0px;">
                        <div class="fixed-table-body" th:with="tid=${teamGroup.id}">
                            <form id="form-plan-edit" action="/plan/edit" method="post">
                                <input type="hidden" name="tid" th:value="${teamGroup.id}"/>
                                <table id="bootstrap-table" class="table table-bordered table-hover"
                                       th:with="bc=${shifts.size}">
                                    <thead class="">
                                    <tr>
                                        <th style="text-align: center;">
                                            <div class="th-inner ">职员</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center;" th:colspan="${bc}">
                                            <div class="th-inner ">星期一</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center;" th:colspan="${bc}">
                                            <div class="th-inner ">星期二</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center;" th:colspan="${bc}">
                                            <div class="th-inner ">星期三</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center;" th:colspan="${bc}">
                                            <div class="th-inner ">星期四</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center;" th:colspan="${bc}">
                                            <div class="th-inner ">星期五</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; " th:colspan="${bc}">
                                            <div class="th-inner ">星期六</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; " th:colspan="${bc}">
                                            <div class="th-inner ">星期日</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody th:with="tds=${7 * bc -1}">
                                    <tr class="no-records-found">
                                        <td></td>
                                        <td th:each="n:${#numbers.sequence(0, tds)}">[[${shifts[n%bc].shift}]]</td>
                                    </tr>
                                    <tr class="no-records-found" th:each="user:${users}">
                                        <td>[[${user.userName}]]</td>
                                        <td th:each="n:${#numbers.sequence(0,tds)}"
                                            th:with="sid=${shifts[n%bc].id},day=${n/bc+1},key=${#strings.concat(tid,sid,user.userId,day)}"
                                            th:style="${#strings.concat('background:',planMap.get(key)== 1?'#00CCFF':'none')}">
                                            <input type="checkbox" name="works"
                                                   th:value="|${tid},${sid},${user.userId},${day},Y|"
                                                   onclick="selected(this)" th:checked="${planMap.get(key)== 1?'true':'false'}"/>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                        <div class="fixed-table-footer">
                            <div class="fixed-table-toolbar">
                                <div class="bs-bars pull-left">
                                    <div class="btn-group-sm" id="toolbar" role="group">
                                        <button id="submit-btn" class="btn btn-success" onclick="submitHandler()">
                                            <i class="fa fa-plus"></i> 提交
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "his/plan";
        $("#form-plan-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveModal(prefix + "/edit", $('#form-plan-edit').serialize(), callback);
            }
        }

        function callback(result) {
            if (result.code == web_status.SUCCESS) {
                $.modal.alertSuccess(result.msg);
                $("#submit-btn").attr("disabled",true);
            } else if (result.code == web_status.WARNING) {
                $.modal.alertWarning(result.msg);
            } else {
                $.modal.alertError(result.msg);
            }
            $.modal.closeLoading();
        }

        function selected(obj) {
            if (obj.checked) {
                obj.parentNode.style.background = "#00CCFF";
            } else {
                obj.parentNode.style.background = "none";
            }
        }
    </script>
</body>
</html>